package cn.itsource.hrm.feignclients;


import cn.itsource.hrm.doc.ESBaseQuery;
import cn.itsource.hrm.doc.CourseDoc;
import cn.itsource.hrm.fallback.ESFeignClientFallbackFactory;
import cn.itsource.hrm.query.CourseQuery;
import cn.itsource.hrm.util.AjaxResult;
import cn.itsource.hrm.util.PageList;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.web.bind.annotation.*;

//value属性：调用目标服务的服务名
@FeignClient(value="es-server", fallbackFactory = ESFeignClientFallbackFactory.class)
public interface ESFeignClient {

    //添加课程
    @PostMapping("/es/save")
    AjaxResult save(@RequestBody CourseDoc courseDoc);

    @DeleteMapping("/es/deleteById/{id}")
    AjaxResult deleteById(@PathVariable("id")Long id);

    @PostMapping("/es/search")
    PageList<CourseDoc> search(@RequestBody NativeSearchQueryBuilder nativeSearchQueryBuilder);

    @PostMapping("/es/searchString")
    PageList<CourseDoc> searchString(@RequestBody String json);

    //测试代码
    @RequestMapping(value = "/es/searchBaseQuery" , method = RequestMethod.POST,consumes = "application/json")
    PageList<CourseDoc> searchBaseQuery(@RequestBody ESBaseQuery esBaseQuery);

    @PostMapping("/es/searchCourse")
    PageList<CourseDoc> searchCourse(@RequestBody CourseQuery courseQuery);
}
